package com.heima.controller;

import com.heima.model.behavior.dtos.LikesBehaviorDto;
import com.heima.model.behavior.dtos.ReadBehaviorDto;
import com.heima.model.behavior.dtos.UnLikesBehaviorDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.service.BehaviorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author chenshan
 */
@RestController
@RequestMapping("api/v1")
public class BehaviorController {
    @Autowired
    private BehaviorService behaviorService;

    /**
     * 用户行为 - 给文章点赞
     * @param behaviorDto 点赞文章信息
     * @return ResponseResult
     */
    @PostMapping("likes_behavior")
    public ResponseResult likesBehavior(@RequestBody LikesBehaviorDto behaviorDto) {
        return behaviorService.likesBehavior(behaviorDto);
    }

    /**
     * 用户行为 - 阅读文章(阅读文章的次数)
     * @param behaviorDto 用户阅读文章次数
     * @return ResponseResult
     */
    @PostMapping("read_behavior")
    public ResponseResult readBehavior(@RequestBody ReadBehaviorDto behaviorDto) {
        return behaviorService.readBehavior(behaviorDto);
    }

    /**
     * 用户行为 - 不喜欢此文章
     * @param behaviorDto 是否不喜欢
     * @return ResponseResult
     */
    @PostMapping("un_likes_behavior")
    public ResponseResult unlikesBehavior(@RequestBody UnLikesBehaviorDto behaviorDto) {
        return behaviorService.unlikesBehavior(behaviorDto);
    }
}
